//
//  CZQDefaultView.m
//  weibo
//
//  Created by Apple on 15-2-1.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "CZQDefaultView.h"
@interface CZQDefaultView()
/**
 *  图标
 */
@property (weak, nonatomic) IBOutlet UIImageView *icon;
/**
 *  描述
 */
@property (weak, nonatomic) IBOutlet UILabel *descriptionLb;

/**
 *  定时器
 */
@property (nonatomic, strong) CADisplayLink *link;


/**
 *  登陆按钮
 */
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
/**
 *  注册按钮
 */
@property (weak, nonatomic) IBOutlet UIButton *registerBtn;
/**
 *  点击登陆按钮
 */
- (IBAction)loginBtnOnClick:(UIButton *)sender;
/**
 *  点击注册按钮
 */
- (IBAction)registerBtnOnClick:(UIButton *)sender;
@end

@implementation CZQDefaultView

#pragma mark - 懒加载
- (CADisplayLink *)link
{
    if (!_link) {
        _link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
    }
    return _link;
}

+ (instancetype)defaultCenterView{

    return [[[NSBundle mainBundle] loadNibNamed:@"CZQDefaultView" owner:nil options:nil] lastObject];

}
- (void)setIconImageName:(NSString *)iconImageName{

    self.icon.image = [UIImage imageNamed:iconImageName];

}
- (void)setInfo:(NSString *)info{

    self.descriptionLb.text = info;
}

/**
 *  开始转动
 */
- (void)startRotate{

    [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];

}
- (void)stopRotate
{
    [self.link invalidate];
    self.link = nil;
}
- (void)update
{
    self.turntableIv.transform = CGAffineTransformRotate(self.turntableIv.transform, M_PI/100);
}

/**
 *  点击登陆按钮
 */
- (IBAction)loginBtnOnClick:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(defaultCenterView:didClickLogin:)]) {
        [self.delegate defaultCenterView:self didClickLogin:sender];
    }
}
/**
 *  点击注册按钮
 */
- (IBAction)registerBtnOnClick:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(defaultCenterView:didClickRegister:)]) {
        [self.delegate defaultCenterView:self didClickRegister:sender];
    }
}


@end
